package com.bsoft.hospitalchs.ui.main;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.bsoft.hospitalchs.R;
import com.bsoft.hospitalchs.base.BaseActivity;
import com.bsoft.hospitalchs.ui.archives.ArchivesActivity;
import com.bsoft.hospitalchs.ui.home.HomeActivity;
import com.bsoft.hospitalchs.ui.subscribe.SubscribeActivity;
import com.bsoft.hospitalchs.utils.SpUtils;
import com.bsoft.hospitalchs.utils.ToastUtils;
import com.bsoft.hospitalchs.widget.CustomProgress;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by 泅渡者
 * Created on 2017/6/9.
 */

public class MainActivity extends BaseActivity<MainContract.Presenter> implements MainContract.View {


    @Bind(R.id.rl_chaxun)
    RelativeLayout rlChaxun;
    @Bind(R.id.rl_jiandang)
    RelativeLayout rlJiandang;
    @Bind(R.id.rl_guahao)
    RelativeLayout rlGfuahao;
    @Bind(R.id.rl_yuyue)
    RelativeLayout rlYuyue;
    @Bind(R.id.rl_suifang)
    RelativeLayout rlSuifang;
    @Bind(R.id.activity_main)
    LinearLayout activityMain;
    @Bind(R.id.et_iptext)
    EditText etIptext;
    @Bind(R.id.btn_save)
    Button btnSave;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);

        String YiIP = (String) SpUtils.get(MainActivity.this, "YiIP", "219.234.5.196:8066");
        etIptext.setText(YiIP);

    }

    @Override
    public void hideLoading() {
        if (customProgress != null) {
            customProgress.dismiss();
        }
    }

    @Override
    public void showLoadingDialog() {
        customProgress = CustomProgress.show(this, "正在加载...", true, null);
    }


    @OnClick({R.id.rl_chaxun, R.id.rl_jiandang, R.id.rl_guahao, R.id.rl_yuyue, R.id.rl_suifang,R.id.btn_save})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.rl_chaxun:
                startActivity(new Intent(this, HomeActivity.class));
                break;
            case R.id.rl_jiandang:
                startActivity(new Intent(this, ArchivesActivity.class));
                break;
            case R.id.rl_guahao:
                break;
            case R.id.rl_yuyue:
                Intent intent = new Intent(this, SubscribeActivity.class);
                intent.putExtra("Client", 0);
                startActivity(intent);
                break;
            case R.id.rl_suifang:
                break;
            case R.id.btn_save:
                SpUtils.put(MainActivity.this, "YiIP", etIptext.getText().toString().trim());
                ToastUtils.showShort("保存成功");
                break;
        }
    }
}
